﻿<UserControl
    x:Class="Rio.Framework.Pages.Workflow.AdministrationFlowTab"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:Rio_Framework_Pages_Controls="clr-namespace:Rio.Framework.Pages.Controls"
    xmlns:Rio_Framework_Pages_Workflow="clr-namespace:Rio.Framework.Pages.Workflow"
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
    xmlns:split="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" 
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <UserControl.Resources>

        <telerik:ContainerBindingCollection x:Key="ContainerBindings">
            <telerik:ContainerBinding PropertyName="IsExpanded"
                                      Binding="{Binding bIsExpanded}" />
            <telerik:ContainerBinding PropertyName="IsSelected"
                                      Binding="{Binding bIsSelected}" />
            <telerik:ContainerBinding PropertyName="IsDropAllowed"
                                      Binding="{Binding bIsDropAllowed}" />
            <telerik:ContainerBinding PropertyName="DefaultImageSrc"
                                      Binding="{Binding sImageSrc}" />
        </telerik:ContainerBindingCollection>

        <DataTemplate x:Key="EditTreeViewTemplate">
            <TextBox x:Uid="{Binding IdRepertory}"
                     Text="{Binding Text, Mode=TwoWay}" />
        </DataTemplate>

        <telerik:HierarchicalDataTemplate x:Key="TreeViewItemTemplate"
                                          ItemsSource="{Binding Items}"
                                          telerik:ContainerBinding.ContainerBindings="{StaticResource ContainerBindings}">
            <TextBlock x:Uid="{Binding iIdRepertory}"
                       Text="{Binding sText}"
                       FontWeight="{Binding TextFont}" />

        </telerik:HierarchicalDataTemplate>

        <ControlTemplate x:Key="TreeViewItemDefaultTemplate"
                         TargetType="telerik:RadTreeViewItem">
            <Grid x:Name="RootElement">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name="EditStates">
                        <VisualState x:Name="Display" />
                        <VisualState x:Name="Edit">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Duration="0"
                                                               Storyboard.TargetProperty="Visibility"
                                                               Storyboard.TargetName="EditHeaderElement">
                                    <DiscreteObjectKeyFrame KeyTime="0"
                                                            Value="Visible" />
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Duration="0"
                                                               Storyboard.TargetProperty="Visibility"
                                                               Storyboard.TargetName="Header">
                                    <DiscreteObjectKeyFrame KeyTime="0"
                                                            Value="Collapsed" />
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                    <VisualStateGroup x:Name="CommonStates">
                        <VisualState x:Name="Normal" />
                        <VisualState x:Name="Disabled">
                            <Storyboard>
                                <DoubleAnimation Duration="0:0:0.0"
                                                 To="0.35"
                                                 Storyboard.TargetProperty="Opacity"
                                                 Storyboard.TargetName="Header" />
                                <DoubleAnimation Duration="0:0:0.0"
                                                 To="0.35"
                                                 Storyboard.TargetProperty="Opacity"
                                                 Storyboard.TargetName="Image" />
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="MouseOver">
                            <Storyboard>
                                <DoubleAnimation Duration="0:0:0.1"
                                                 To="1"
                                                 Storyboard.TargetProperty="Opacity"
                                                 Storyboard.TargetName="MouseOverVisual" />
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                    <VisualStateGroup x:Name="SelectionStates">
                        <VisualState x:Name="Unselected" />
                        <VisualState x:Name="Selected">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Duration="0"
                                                               Storyboard.TargetProperty="Visibility"
                                                               Storyboard.TargetName="SelectionVisual">
                                    <DiscreteObjectKeyFrame KeyTime="0"
                                                            Value="Visible" />
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="SelectedUnfocused">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Duration="0"
                                                               Storyboard.TargetProperty="Visibility"
                                                               Storyboard.TargetName="SelectionUnfocusedVisual">
                                    <DiscreteObjectKeyFrame KeyTime="0"
                                                            Value="Visible" />
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                    <VisualStateGroup x:Name="LoadingOnDemandStates">
                        <VisualState x:Name="LoadingOnDemand">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Duration="0"
                                                               Storyboard.TargetProperty="Visibility"
                                                               Storyboard.TargetName="LoadingVisual">
                                    <DiscreteObjectKeyFrame KeyTime="0"
                                                            Value="Visible" />
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Duration="0"
                                                               Storyboard.TargetProperty="Visibility"
                                                               Storyboard.TargetName="Expander">
                                    <DiscreteObjectKeyFrame KeyTime="0"
                                                            Value="Collapsed" />
                                </ObjectAnimationUsingKeyFrames>
                                <DoubleAnimation Duration="0:0:1"
                                                 From="0"
                                                 RepeatBehavior="Forever"
                                                 To="359"
                                                 Storyboard.TargetProperty="Angle"
                                                 Storyboard.TargetName="LoadingVisualAngleTransform" />
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="LoadingOnDemandReverse" />
                    </VisualStateGroup>
                    <VisualStateGroup x:Name="FocusStates">
                        <VisualState x:Name="Focused">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Duration="0"
                                                               Storyboard.TargetProperty="Visibility"
                                                               Storyboard.TargetName="FocusVisual">
                                    <DiscreteObjectKeyFrame KeyTime="0"
                                                            Value="Visible" />
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="Unfocused" />
                    </VisualStateGroup>
                    <VisualStateGroup x:Name="ExpandStates">
                        <VisualState x:Name="Expanded" />
                        <VisualState x:Name="Collapsed" />
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
                <Grid x:Name="HeaderRow"
                      Background="Transparent"
                      MinHeight="{TemplateBinding MinHeight}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Border BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Background="{TemplateBinding Background}"
                            Grid.ColumnSpan="6"
                            Grid.Column="2"
                            CornerRadius="2" />
                    <Border x:Name="MouseOverVisual"
                            BorderBrush="{StaticResource ControlSubItem_OuterBorder_MouseOver}"
                            BorderThickness="{StaticResource ControlSubItem_OuterBorderThickness}"
                            Grid.ColumnSpan="6"
                            Grid.Column="2"
                            CornerRadius="{StaticResource ControlSubItem_OuterCornerRadius}"
                            Opacity="0">
                        <Border BorderBrush="{StaticResource ControlSubItem_InnerBorder_MouseOver}"
                                BorderThickness="{StaticResource ControlSubItem_InnerBorderThickness}"
                                Background="{StaticResource ControlSubItem_Background_MouseOver}"
                                CornerRadius="{StaticResource ControlSubItem_InnerCornerRadius}" />
                    </Border>
                    <Border x:Name="SelectionUnfocusedVisual"
                            BorderBrush="{StaticResource ControlSubItem_OuterBorder_UnFocus}"
                            BorderThickness="{StaticResource ControlSubItem_OuterBorderThickness}"
                            Grid.ColumnSpan="6"
                            Grid.Column="2"
                            CornerRadius="{StaticResource ControlSubItem_OuterCornerRadius}"
                            Visibility="Collapsed">
                        <Border BorderBrush="{StaticResource ControlSubItem_InnerBorder_UnFocus}"
                                BorderThickness="{StaticResource ControlSubItem_InnerBorderThickness}"
                                Background="{StaticResource ControlSubItem_Background_UnFocus}"
                                CornerRadius="{StaticResource ControlSubItem_InnerCornerRadius}" />
                    </Border>
                    <Border x:Name="SelectionVisual"
                            BorderBrush="{StaticResource ControlSubItem_OuterBorder_Selected}"
                            BorderThickness="{StaticResource ControlSubItem_OuterBorderThickness}"
                            Grid.ColumnSpan="6"
                            Grid.Column="2"
                            CornerRadius="{StaticResource ControlSubItem_OuterCornerRadius}"
                            Visibility="Collapsed">
                        <Border BorderBrush="{StaticResource ControlSubItem_InnerBorder_Selected}"
                                BorderThickness="{StaticResource ControlSubItem_InnerBorderThickness}"
                                Background="{StaticResource ControlSubItem_Background_Selected}"
                                CornerRadius="{StaticResource ControlSubItem_InnerCornerRadius}" />
                    </Border>
                    <StackPanel x:Name="IndentContainer"
                                Orientation="Horizontal">
                        <Rectangle x:Name="IndentFirstVerticalLine"
                                   Stroke="{StaticResource TreeView_LineColor}"
                                   Visibility="Collapsed"
                                   VerticalAlignment="Top"
                                   Width="1">
                            <Rectangle.Clip>
                                <RectangleGeometry Rect="0,0,1,10000" />
                            </Rectangle.Clip>
                        </Rectangle>
                    </StackPanel>
                    <Grid x:Name="ListRootContainer"
                          Grid.Column="1"
                          HorizontalAlignment="Center"
                          MinWidth="20">
                        <Rectangle x:Name="HorizontalLine"
                                   HorizontalAlignment="Right"
                                   Height="1"
                                   Stroke="{StaticResource TreeView_LineColor}"
                                   VerticalAlignment="Center">
                            <Rectangle.Clip>
                                <RectangleGeometry Rect="0,0,10000,1" />
                            </Rectangle.Clip>
                        </Rectangle>
                        <Rectangle x:Name="VerticalLine"
                                   HorizontalAlignment="Center"
                                   Stroke="{StaticResource TreeView_LineColor}"
                                   VerticalAlignment="Top"
                                   Width="1">
                            <Rectangle.Clip>
                                <RectangleGeometry Rect="0,0,1,10000" />
                            </Rectangle.Clip>
                        </Rectangle>
                        <ToggleButton x:Name="Expander"
                                      Background="{TemplateBinding Background}"
                                      IsTabStop="False" />
                        <Grid x:Name="LoadingVisual"
                              HorizontalAlignment="Center"
                              RenderTransformOrigin="0.5,0.5"
                              Visibility="Collapsed"
                              VerticalAlignment="Center">
                            <Grid.RenderTransform>
                                <TransformGroup>
                                    <RotateTransform x:Name="LoadingVisualAngleTransform"
                                                     Angle="0"
                                                     CenterY="0.5"
                                                     CenterX="0.5" />
                                </TransformGroup>
                            </Grid.RenderTransform>
                            <Path Data="M1,0 A1,1,90,1,1,0,-1"
                                  Height="10"
                                  StrokeStartLineCap="Round"
                                  Stretch="Fill"
                                  Stroke="{TemplateBinding Foreground}"
                                  StrokeThickness="1"
                                  Width="10" />
                            <Path Data="M0,-1.1 L0.1,-1 L0,-0.9"
                                  Fill="{TemplateBinding Foreground}"
                                  HorizontalAlignment="Left"
                                  Height="4"
                                  Margin="5,-1.5,0,0"
                                  Stretch="Fill"
                                  StrokeThickness="1"
                                  VerticalAlignment="Top"
                                  Width="4" />
                        </Grid>
                    </Grid>
                    <CheckBox x:Name="CheckBoxElement"
                              Grid.Column="2"
                              IsTabStop="False"
                              Margin="5,0,0,0"
                              telerik:StyleManager.Theme="{StaticResource Theme2}"
                              Visibility="Collapsed"
                              VerticalAlignment="Center" />
                    <RadioButton x:Name="RadioButtonElement"
                                 Grid.Column="2"
                                 IsTabStop="False"
                                 Margin="5,0,0,0"
                                 telerik:StyleManager.Theme="{StaticResource Theme2}"
                                 Visibility="Collapsed"
                                 VerticalAlignment="Center" />
                    <Image x:Name="Image"
                           Grid.Column="3"
                           HorizontalAlignment="Center"
                           MaxWidth="16"
                           MaxHeight="16"
                           Margin="2"
                           Tag="Wow"
                           VerticalAlignment="Center" />
                    <Rectangle x:Name="FocusVisual"
                               Grid.ColumnSpan="6"
                               Grid.Column="2"
                               IsHitTestVisible="False"
                               RadiusY="3"
                               RadiusX="3"
                               Stroke="{StaticResource FocusBrushBlack}"
                               StrokeThickness="1"
                               StrokeDashArray="1 2"
                               Visibility="Collapsed" />
                    <Grid Grid.ColumnSpan="2"
                          Grid.Column="4">
                        <ContentPresenter x:Name="Header"
                                          ContentTemplate="{TemplateBinding HeaderTemplate}"
                                          Content="{TemplateBinding Header}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          Margin="{TemplateBinding Padding}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                        <ContentPresenter x:Name="EditHeaderElement"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          Margin="{TemplateBinding Padding}"
                                          Visibility="Collapsed"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                    </Grid>
                </Grid>
                <ItemsPresenter x:Name="ItemsHost"
                                Grid.Row="1"
                                Visibility="Collapsed" />
            </Grid>
        </ControlTemplate>        

    </UserControl.Resources>

    <Grid x:Name="LayoutRoot" Background="White">
    	<Grid.ColumnDefinitions>
    		<ColumnDefinition Width="200"/>
    		<ColumnDefinition Width="10"/>
    		<ColumnDefinition Width="*"/>
    	</Grid.ColumnDefinitions>
    	<Grid.RowDefinitions>
    		<RowDefinition Height="Auto"/>
    		<RowDefinition Height="*"/>
    	</Grid.RowDefinitions>

        <!--UCOrganizationTypePanel-->
        <Rio_Framework_Pages_Controls:UCOrganizationTypePanel x:Name="OrganizationType" Grid.Row="0" Grid.ColumnSpan="3"/>

        <!--Treeview-->
        <telerik:RadTreeView x:Name="RadTreeViewBox" Grid.Row="1" Grid.Column="0"
                                                     ItemTemplate="{StaticResource TreeViewItemTemplate}"
                                                     ItemEditTemplate="{StaticResource EditTreeViewTemplate}"
                                                     IsExpandOnSingleClickEnabled="True"
                                                     IsLineEnabled="True"
                                                     IsEditable="True"
                                                     telerik:RadDragAndDropManager.AllowDrop="True"
                                                     IsDragDropEnabled="True"
                                                     ItemsSource="{Binding ItemsTreeView}"
                                                     SelectionChanged="RadTreeViewBox_SelectionChanged"
                                                     Margin="5,5,5,0" />

        <!--GridSplitter-->
        <split:GridSplitter Grid.Row="1" 
                            Grid.Column="1" 
                            Name="SplitBar"
                            Width="8" 
                            HorizontalAlignment="Stretch" 
                            VerticalAlignment="Stretch"
                            ShowsPreview="True" />

        <!--WorkflowInstanceList-->
        <Rio_Framework_Pages_Workflow:WorkflowInstanceList x:Name="WorkflowInstanceList" Grid.Row="1" Grid.Column="2" />
        
    </Grid>
    
</UserControl>
